package com.tinysand.advert.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

/**
 * 实现了 WebMvcConfigurer 接口的配置类。覆写其中方法，定义消息转换器
 *
 * Created By TINY
 * Create Time 2020/2/14
 **/
@Configuration
public class WebMvcConfiguration implements WebMvcConfigurer {

    @Override
    public void configureMessageConverters(
            List<HttpMessageConverter<?>> converters) {
        converters.clear(); // 不使用Spring默认提供的转换器

        converters.add(new MappingJackson2HttpMessageConverter());
    }
}
